package com.nightpiter.controller.threads;

import com.nightpiter.controller.MetroController;
import com.nightpiter.model.MetroModel;
import com.nightpiter.model.objects.Station;

import android.graphics.PointF;
import android.os.Handler;

/**
 * StationSearcherThread class.
 * 
 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
 */
public class StationSearcherThread extends Thread {

	/**
	 * point to search the nearest Station
	 */
	private PointF point;

	/**
	 * model to search a station in
	 */
	private MetroModel model;

	/**
	 * handler from UI thread
	 */
	private Handler handler;

	/**
	 * default constructor
	 */
	public StationSearcherThread(PointF point, MetroModel model, Handler handler) {
		super("StationSearcherThread");
		this.point = point;
		this.model = model;
		this.handler = handler;
	}

	@Override
	public void run() {
		super.run();
		Station foundStation = this.model.searchStation(point);
		handler.sendMessage(handler.obtainMessage(
				MetroController.MSG_STATION_RETRIEVED, foundStation));
	}

}
